import java.util.*;

interface GeneralStack<E> {

	public E push(E item);

	public E pop();

	public E peek();

	public boolean empty();

	public int size();
}

class ArrayListGeneralStack<E> implements GeneralStack<E> {
	private List<E> list;

	public ArrayListGeneralStack() {
		list = new ArrayList<E>();
	}

	@Override
	public E push(E item) {
		if (item == null)
			return null;
		list.add(item);
		return item;
	}

	@Override
	public E pop() {
		if (list.isEmpty())
			return null;
		return list.remove(list.size() - 1);
	}

	@Override
	public E peek() {

		if (list.isEmpty())
			return null;
		return list.get(list.size() - 1);
	}

	@Override
	public boolean empty() {

		return list.isEmpty();
	}

	@Override
	public int size() {

		return list.size();
	}

	@Override
	public String toString() {
		return list.toString();
	}
}

class Car {

	private int id;
	private String name;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Override
	public String toString() {
		return "Car [id=" + id + ", name=" + name + "]";
	}
}

public class Main1 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			String str = sc.next();
			int num = -1;
			if (str.equals("Integer"))
				num = 0;
			else if (str.equals("Double"))
				num = 1;
			else if (str.equals("Car"))
				num = 2;
			int m = sc.nextInt();
			int n = sc.nextInt();
			switch (num) {
			case 0:
				System.out.println("Integer Test");
				GeneralStack<Integer> stack = new ArrayListGeneralStack<Integer>();
				for (int i = 0; i < m; i++) {
					int x = sc.nextInt();
					stack.push(x);
					System.out.println("push:" + x);
				}
				for (int j = 0; j < n; j++) {
					System.out.println("pop:" + stack.pop());
				}
				System.out.println(stack);
				int sum = 0;
				while (!stack.empty()) {
					sum += stack.pop();
				}

				System.out.println("sum=" + sum);
				System.out.println(stack.getClass().getInterfaces()[0]);
				break;
			case 1:
				System.out.println("Double Test");
				GeneralStack<Double> stack1 = new ArrayListGeneralStack<Double>();
				for (int i = 0; i < m; i++) {
					double y = sc.nextDouble();
					stack1.push(y);
					System.out.println("push:" + y);
				}
				for (int j = 0; j < n; j++) {
					System.out.println("pop:" + stack1.pop());
				}
				System.out.println(stack1);
				double sum1 = 0;
				while (!stack1.empty()) {
					sum1 += stack1.pop();
				}
				System.out.println("sum=" + sum1);
				System.out.println(stack1.getClass().getInterfaces()[0]);
				break;
			case 2:
				System.out.println("Car Test");
				GeneralStack<Car> stack2 = new ArrayListGeneralStack<Car>();
				for (int i = 0; i < m; i++) {
					Car car = new Car();
					car.setId(sc.nextInt());
					car.setName(sc.next());
					stack2.push(car);
					System.out.println("push:" + car);
				}
				for (int j = 0; j < n; j++) {
					System.out.println("pop:" + stack2.pop());
				}
				System.out.println(stack2);
				while (!stack2.empty()) {
					System.out.println(stack2.pop().getName());

				}
				System.out.println(stack2.getClass().getInterfaces()[0]);
				break;
			}

			if (str.equals("quit"))
				break;
		}
		sc.close();
	}
}
